home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 23
/
AACD 23.iso
/
AACD
/
Online
/
WebYAM
/
TextMode.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
2000-09-20
|
7KB
|
224 lines
/*
** $VER: TextMode 1.5 (19.2.2000)
** © 1999-2000 by Jacob Laursen <laursen@myself.com>
**
** Browse YAM folders from shell
**
** Requirements: YAM 2.0
**
** For "quoted printable" -> "8bit" conversion, please download
** comm/mail/YToolsNG.lha from Aminet and copy the file 'YTCunmime'
** to the YAM: directory, or correct the path below.
**
** Changes since version 1.4: - Completed 'HELP STATUS'.
** - File 'TextMode.folders' is no longer used.
** Instead, YAM's own .folders file is parsed
**
** Changes since version 1.3: - Added flags/status and header to LIST.
** - Added 'HELP STATUS' for information on
** message flags/status.
**
** Changes since version 1.2: - LISTFOLDERS didn't like separator lines
** - Added command HELP
** - Error message when going to a non-existing
** folder or message is now handled internally
*/
options results
options failat 11
signal on break_d
/* Name of text file to save name of folders in (for speedup) */
FoldersFile = 'YAM:Rexx/TextMode.folders'
/* YAM executable path */
YAMPath = 'YAM:YAM'
/* YTCunmime executable path */
UMPath = 'YAM:YTCunmime'
/* YAM folders file */
YAMFolders = 'YAM:.folders'
/* No user-serviceable parts below... */
if ~show('P','YAM') then do
writech(stdout,'Loading YAM')
address command 'run <>nil: ' || YAMPath || ' HIDE'
do while ~show('P','YAM')
writech(stdout,'.')
call delay(100)
end
writech(stdout,'0d'x)
end
address 'YAM'
say 'Welcome to the world of Yet Another Mailer.'
say 'CLI-interface by Jacob Laursen'
say ''
call Help
say ''
/* Why doesn't ARexx have a GOTO command? */
FirstRun = 1
break_c:
signal on break_c
if FirstRun = 0 then say '*** Break'
else FirstRun = 0
/* Main loop */
do while (option ~= 'QUIT' & option ~= 'EXIT')
FOLDERINFO STEM fi.
call WRITECH(STDOUT,fi.NUMBER || '.' || fi.NAME || '> ')
option = upper(READLN(STDIN))
/* Commands... */
if (word(option,1) = 'FOLDER' | word(option,1) = 'GOTOFOLDER') then do
SETFOLDER word(option,2)
if RC = 10 then say 'This folder does not exist. Please update folder list with `LISTFOLDERS UPDATE'''
end
if word(option,1) = 'GOTO' then do
if words(option) = 2 then call GotoMail(word(option,2))
end
if word(option,1) = 'READ' then do
if words(option) = 2 then RC = GotoMail(word(option,2))
else RC = 0
if RC = 10 then break
MAILEXPORT 'T:YAM-TextMode.tmp'
if exists(UMPath) = 1 then address command UMPath || ' MAIL=T:YAM-TextMode.tmp'
address command 'Type T:YAM-TextMode.tmp'
address command 'Delete >NIL: T:YAM-TextMode.tmp'
end
if option = 'LIST' then do
FOLDERINFO STEM fi.
say 'No. Name Subject Date Time Size Flags'
say '--- ----------------------- -------------------- -------- -------- ------ -----'
do loop = 0 to fi.TOTAL-1
SETMAIL loop
MAILINFO STEM sel.
if index(sel.FROM,'<') ~= 0 then email = left(sel.FROM,index(sel.FROM,'<')-2)
else email = sel.FROM
say left(sel.INDEX,4,' ') || left(email,23,' ') || ' ' || left(sel.SUBJECT,20,' ') || ' ' || sel.DATE || ' ' || WriteAlignRight(sel.SIZE,6) || ' ' || left(sel.FLAGS,4) || sel.STATUS
end
say
end
if word(option,1) = 'LISTFOLDERS' then do
if (word(option,2) = 'UPDATE' | ~exists(YAMFolders)) then do
say 'No. Folder Total Unr. New'
say '--- ------------------------------ ----- ----- -----'
currentfolder = fi.NUMBER
i = 0
do forever
SETFOLDER i
if RC = 10 then do
SETFOLDER i+1
if RC = 10 then leave
/* Workaround for separator lines. Two in a row still breaks this routine */
else say '--- ------------------------------ ----- ----- -----'
i = i + 1
iterate
end
FOLDERINFO STEM cfi.
say left(cfi.NUMBER,4,' ') || left(cfi.NAME,30,' ') || ' ' || WriteAlignRight(cfi.TOTAL,5) || ' ' || WriteAlignRight(cfi.UNREAD,5) || ' ' || WriteAlignRight(cfi.NEW,5)
i = i + 1
end
SETFOLDER currentfolder
end
else do
say 'No. Folder '
say '--- ------------------------------'
call open(fh, YAMFolders, 'R')
i = 0
do while ~eof(fh)
line = readln(fh)
if word(line, 1) = '@FOLDER' then do
say left(i, 4, ' ') || right(line,length(line)-8)
i = i + 1
end
else if word(line, 1) = '@SEPARATOR' then do
if length(line) > 11 then do
full = '------------------------------'
sname = right(line,length(line)-11)
sep = '--- ' || left(full, trunc((30-length(sname))/2)) || sname || left(full, trunc((30-length(sname))/2))
if length(sname)/2 ~= trunc(length(sname)/2) then sep = sep || '-'
say sep
end
else say '--- ------------------------------'
i = i + 1
end
end
call close(fh)
end
say
end
if option = 'GET' then MAILCHECK
if word(option,1) = 'HELP' then do
if words(option) = 1 then call Help
else if word(option,2) = 'STATUS' then do
say 'MARCX: M = Multiple recipients'
say ' A = Attachments'
say ' R = Report'
say ' C = Encrypted'
say ' X = N, O, U, R, F, S, W, H or E'
say ' N = New'
say ' O = Old'
say ' U = Unread'
say ' R = Replied'
say ' F = Forwarded'
say ' S = Sent'
say ' W = WaitSend'
say ' H = Hold'
say ' E = Error'
end
end
end
exit
WriteAlignRight: PROCEDURE
parse arg OldString, Length
NewString = copies(' ',Length-length(OldString)) || OldString
return NewString
GotoMail: PROCEDURE
parse arg num
SETMAIL num
if RC ~= 10 then return 0
else say 'This mail does not exist. Please re-read index with `LIST'''
return 10
Help: PROCEDURE
say 'Commands: QUIT or EXIT Exit program'
say ' LISTFOLDERS [UPDATE] List folders'
say ' GOTOFOLDER <folder-#> Change current folder'
say ' LIST List messages in current folder'
say ' GOTO <message-#> Change current message'
say ' READ [<message-#>] Read current or selected message'
say ' GET Get new mail'
say ' HELP [STATUS] Display this text or status info'
return
break_d:
say '*** Execution halted'
exit